<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<jsp:useBean id="change" class="database.DbUserSonstiges"
	scope="request" />
<jsp:setProperty name="change" property="*" />
<jsp:setProperty name="change" property="userID"
	value="${sessionScope.id}" />


<script type="text/javascript">
function redirect_index(code){
    window.opener.location = '../index.jsp?success=' + code;
    window.close();
}
</script>

<script type="text/javascript">
function redirect_konto(code){
    window.opener.location = '../Startseite/konto.jsp?error=' + code;
    window.close();
}
</script>

<c:choose>
	<c:when test="${change.mode eq 'username'}">
		<c:set var="test" value="${change.checkusername()}" scope="request" />
		<c:if test="${test}">
			${change.usernameAendern()}
			<c:remove var="id" />
			<c:remove var="username" />
			<script type="text/javascript">
			redirect_index(4);
			</script>
		</c:if>
		<c:if test="${!test}">
			<script type="text/javascript">
			redirect_konto(1);
			</script>
		</c:if>
	</c:when>
	<c:when test="${change.mode eq 'pw'}">
		<c:set var="test" value="${change.PasswortAendern()}" scope="request" />
		<c:if test="${test}">
			<c:remove var="id" />
			<c:remove var="username" />
			<<script type="text/javascript">
			redirect_index(5);
			</script>
		</c:if>
		<c:if test="${!test}">
			<script type="text/javascript">
			redirect_konto(2);
			</script>
		</c:if>
	</c:when>
	<c:when test="${change.mode eq 'email'}">
		<c:set var="test" value="${change.mailAendern()}" scope="request" />
		<c:if test="${test}">
			<c:remove var="id" />
			<c:remove var="username" />
			<script type="text/javascript">
			redirect_index(6);
			</script>
		</c:if>
		<c:if test="${!test}">
			<script type="text/javascript">
			redirect_konto(3);
			</script>
		</c:if>
	</c:when>
	<c:when test="${change.mode eq 'deleteuser'}">
		<c:set var="test" value="${change.UserLoeschen()}" scope="request" />
		<c:if test="${test}">
			<c:remove var="id" />
			<c:remove var="username" />
			<script type="text/javascript">
			redirect_index(7);
			</script>
		</c:if>
		<c:if test="${!test}">
			<script type="text/javascript">
			redirect_konto(4);
			</script>
		</c:if>
	</c:when>
</c:choose>